package com.bird.设计模式.行为型.责任链模式.过滤器功能;

/**
 * @data 2022/10/5 11:41
 * @author: bird
 * @description: 第一步步：编写抽象的处理类
 */
public abstract class Handle<T> {

    /**
     * 和自己一样类型的类
     */
    protected Handle next;


    /**
     * 方法一：指向下一个节点.
     *
     * @param nextNode 参数是处理类
     */
    public void next(Handle nextNode) {
        this.next = nextNode;
    }

    /**
     * 处理这个请求
     */
    public abstract void doHandle(Member member);


    /*+++++++++++++++++++建造者模式 链式编程++++++++++++++++++*/


    public static class Builder<T> {

        private Handle<T> head;// 头节点
        private Handle<T> tail;// 尾节点


        public Builder<T> addBuilder(Handle handle) {
            if (this.head == null) {
                this.head = this.tail = handle;
                return this;
            }
            this.tail.next(handle);
            this.tail = handle;
            return this;

        }

        public Handle<T> build(){
            return this.head;
        }


    }
}
